#include <QDir>
#include <QPixmap>

#include "ciconselectionmodel.h"

CIconSelectionModel::CIconSelectionModel()
{
    QDir dir(":/icons");
    m_data = dir.entryList();
}

int CIconSelectionModel::rowCount(const QModelIndex &) const
{
    return m_data.count();
}

QVariant CIconSelectionModel::data(const QModelIndex &index, int role) const
{
    if(role != Qt::DecorationRole)
        return QVariant();

    QString name = m_data.value(index.row());
    return QPixmap(":/icons/" + name);
}

QString CIconSelectionModel::nameById(int id)
{
    if(m_data.count() <= id)
        return QString();

    return m_data.value(id);
}
